package com.dai.zhenfujin.huanxin.chat;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

import com.dai.zhenfujin.R;
import com.dai.zhenfujin.db.Constant;
import com.hyphenate.chat.EMMessage;

public class ContextMenuActivity extends Activity {
    public static final int RESULT_CODE_COPY = 1;
    public static final int RESULT_CODE_DELETE = 2;
    public static final int RESULT_CODE_FORWARD = 3;
    public static final int RESULT_CODE_RECALL = 4;
    public static final int RESULT_CODE_ADD_EMOJICON = 5;
    public static final int RESULT_SCAN_QR_CODE = 6;
    public static final int RESULT_CODE_SAVE = 7;

    public static final String ONLY_SHOW_QR_CODE = "only_show_qr_code";

    public static final String IS_QR_CODE = "is_qr_code";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EMMessage message = getIntent().getParcelableExtra("message");

        int type = message.getType().ordinal();
        if (type == EMMessage.Type.TXT.ordinal()) {
            if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)) {
                setContentView(R.layout.em_context_menu_for_image);
            } else {
                setContentView(R.layout.em_context_menu_for_text);
            }
        } else if (type == EMMessage.Type.LOCATION.ordinal()) { //位置
            setContentView(R.layout.em_context_menu_for_image);

        } else if (type == EMMessage.Type.IMAGE.ordinal()) { //图片
            setContentView(R.layout.em_context_menu_for_image);
            TextView tv_delete = findViewById(R.id.tv_delete);
            TextView recall = findViewById(R.id.recall);
        }

        if(message.direct() == EMMessage.Direct.RECEIVE)
        {
            View recall = (View) findViewById(R.id.recall);
            recall.setVisibility(View.GONE);
        }
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        finish();
        return true;
    }

    public void copy(View view) {
        setResult(RESULT_CODE_COPY);
        finish();
    }

    public void delete(View view) {
        setResult(RESULT_CODE_DELETE);
        finish();
    }


    /**
     * 撤回
     * @param view
     */
    public void recall(View view) {
        setResult(RESULT_CODE_RECALL);
        finish();
    }

}
